﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace ThresholdAssistant.WebAPI.Models
{
    /// <summary>
    /// 发送短信参数
    /// </summary>
    public class SendSmsParam
    {
        /// <summary>
        /// 请求参数（手机号、姓名、标题、预警值不能为空，且预警值必须大于0）
        /// </summary>
        [Required(ErrorMessage = nameof(ErrorResultEnum.SmsListIsNull))]
        [MinLength(1, ErrorMessage = nameof(ErrorResultEnum.SmsListLessThan0))]
        [MaxLength(500, ErrorMessage = nameof(ErrorResultEnum.SmsListMoreThan500))]
        [JsonProperty("sms_list"), JsonPropertyName("sms_list")]
        public IEnumerable<SmsInfoParam> SmsList { get; set; }
    }

    /// <summary>
    /// 短信内容参数
    /// </summary>
    public class SmsInfoParam
    {
        /// <summary>
        /// 分组id
        /// </summary>
        public string GroupId { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        [JsonProperty("phone"), JsonPropertyName("phone")]
        [Required(ErrorMessage = nameof(ErrorResultEnum.PhoneIsNull))]
        public string Phone { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        [JsonProperty("name"), JsonPropertyName("name")]
        [Required(ErrorMessage = nameof(ErrorResultEnum.NameIsNull))]
        public string Name { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        [JsonProperty("title"), JsonPropertyName("title")]
        [Required(ErrorMessage = nameof(ErrorResultEnum.TitleIsNull))]
        public string Title { get; set; }

        /// <summary>
        /// 预警时间
        /// </summary>
        [JsonProperty("date_time"), JsonPropertyName("date_time")]
        [Required(ErrorMessage = nameof(ErrorResultEnum.DateTimeIsNull))]
        public DateTime DateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 预警值
        /// </summary>
        [JsonProperty("value"), JsonPropertyName("value")]
        public double Value { get; set; }
    }
}
